<?php

class Modules_Common_DB_WorkspaceHasUsers extends BaseObject
{
	public static function GetTableName() {
        return 'workspace_has_users';
    }
    public static function &ById($id) {
        self::GetById($id);
    }
 	public static function &ByUser($id)
    {
    	$mcdt=new Modules_Common_DB_WorkspaceHasUsers();
    	if(count(($ids=$mcdt->GetIds('WHERE users_id="'.Mysql::EscapeString($id).'"')))>0)
        	return $mcdt->GetByIds($ids);
        else
        	return array();
    }
	public static function &SearchByWorkspace($id)
    {
    	$mcdt=new Modules_Common_DB_WorkspaceHasUsers();
    	if(count(($ids=$mcdt->GetIds('WHERE workspace_id="'.Mysql::EscapeString($id).'"')))>0)
        	return $mcdt->GetByIds($ids);
        else
        	return array();
    }
public static function &ValidateWorkspace($user,$account)
    {
    	$mcdt=new Modules_Common_DB_AccountsHasUsers();
    	if(count(($ids=$mcdt->GetIds('WHERE workspace_id="'.Mysql::EscapeString($account).'" and users_id="'.Mysql::EscapeString($user).'"')))==1)
        	return $mcdt->GetByIds($ids);
        else
        	return array();
    }
}